load("@rules_java//java:defs.bzl", "java_library")
load("//tools/bzl:junit.bzl", "junit_tests")

CUSTOM_TRUTH_SUBJECTS = glob([
    "**/*Subject.java",
])

java_library(
    name = "custom-truth-subjects",
    testonly = True,
    srcs = CUSTOM_TRUTH_SUBJECTS,
    deps = [
        "//java/com/google/gerrit/extensions:api",
        "//java/com/google/gerrit/server",
        "//java/com/google/gerrit/truth",
        "//lib:guava",
        "//lib/truth",
    ],
)

junit_tests(
    name = "server_tests",
    size = "large",
    srcs = glob(
        ["**/*.java"],
        exclude = CUSTOM_TRUTH_SUBJECTS,
    ),
    resource_strip_prefix = "resources",
    resources = ["//resources/com/google/gerrit/server"],
    tags = ["no_windows"],
    visibility = ["//visibility:public"],
    runtime_deps = [
        "//java/com/google/gerrit/lucene",
        "//lib/bouncycastle:bcprov",
        "//prolog:gerrit-prolog-common",
    ],
    deps = [
        ":custom-truth-subjects",
        "//java/com/google/gerrit/acceptance/testsuite/project",
        "//java/com/google/gerrit/common:annotations",
        "//java/com/google/gerrit/common:server",
        "//java/com/google/gerrit/entities",
        "//java/com/google/gerrit/exceptions",
        "//java/com/google/gerrit/extensions:api",
        "//java/com/google/gerrit/git",
        "//java/com/google/gerrit/index",
        "//java/com/google/gerrit/index:query_exception",
        "//java/com/google/gerrit/jgit",
        "//java/com/google/gerrit/json",
        "//java/com/google/gerrit/lifecycle",
        "//java/com/google/gerrit/mail",
        "//java/com/google/gerrit/metrics",
        "//java/com/google/gerrit/proto",
        "//java/com/google/gerrit/proto/testing",
        "//java/com/google/gerrit/server",
        "//java/com/google/gerrit/server/account/externalids/testing",
        "//java/com/google/gerrit/server/cache/serialize",
        "//java/com/google/gerrit/server/cache/testing",
        "//java/com/google/gerrit/server/cancellation",
        "//java/com/google/gerrit/server/fixes/testing",
        "//java/com/google/gerrit/server/git/receive:ref_cache",
        "//java/com/google/gerrit/server/ioutil",
        "//java/com/google/gerrit/server/logging",
        "//java/com/google/gerrit/server/project/testing:project-test-util",
        "//java/com/google/gerrit/server/restapi",
        "//java/com/google/gerrit/server/schema",
        "//java/com/google/gerrit/server/schema/testing",
        "//java/com/google/gerrit/server/util/time",
        "//java/com/google/gerrit/sshd",
        "//java/com/google/gerrit/testing:assertable-executor",
        "//java/com/google/gerrit/testing:gerrit-test-util",
        "//java/com/google/gerrit/truth",
        "//lib:gson",
        "//lib:guava",
        "//lib:guava-retrying",
        "//lib:jgit",
        "//lib:jgit-junit",
        "//lib:protobuf",
        "//lib:soy",
        "//lib/auto:auto-value",
        "//lib/auto:auto-value-annotations",
        "//lib/flogger:api",
        "//lib/guice",
        "//lib/mockito",
        "//lib/truth",
        "//lib/truth:truth-java8-extension",
        "//lib/truth:truth-proto-extension",
        "//proto:cache_java_proto",
        "//proto:entities_java_proto",
    ],
)
